package com.example.dessertstoressm.Service.impl;

import com.example.dessertstoressm.Service.*;
import com.example.dessertstoressm.domain.Category;
import com.example.dessertstoressm.domain.Item;
import com.example.dessertstoressm.domain.Product;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CatalogServiceImpl implements CatalogService {
    @Resource
    private CategoryService categoryService;
    @Resource
    private ProductService productService;
    @Resource
    private ItemService itemService;

    @Override
    public List<Category> getCategoryList() {
        return categoryService.getCategoryList();
    }

    @Override
    public Category getCategory(String categoryId) {
        return categoryService.getCategory(categoryId);
    }

    @Override
    public Product getProduct(String productId) {
        return productService.getProduct(productId);
    }

    @Override
    public List<Product> getProductListByCategory(String categoryId) {
        return productService.getProductListByCategory(categoryId);
    }

    @Override
    // TODO enable using more than one keyword
    public List<Product> searchProductList(String keyword) {
        return productService.searchProductList(keyword.toLowerCase());
    }

    @Override
    public List<Item> getItemListByProduct(String productId) {
        return itemService.getItemListByProduct(productId);
    }

    @Override
    public Item getItem(String itemId) {
        return itemService.getItem(itemId);
    }

    @Override
    public boolean isItemInStock(String itemId) {
        return itemService.getInventoryQuantity(itemId) > 0;
    }
}
